package leaveSystem.controller;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import leaveSystem.bizlogic.ViewLeaveManager;
import leaveSystem.model.EmpLeave;
import leaveSystem.model.Leave;

/**
 * Servlet implementation class ViewSubordinateHistoryServlet
 */
@WebServlet("/viewsubordinate")
public class ViewSubordinateHistoryServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ViewSubordinateHistoryServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		int leaveid=Integer.parseInt(request.getParameter("leaveid"));
		ViewLeaveManager manager=new ViewLeaveManager();
				
		EmpLeave empleave=manager.getEmpLeave(leaveid);
		System.out.println("Leave: "+empleave);
		
		request.setAttribute("empleave", empleave);
		request.setAttribute("readonly", "true");
		RequestDispatcher rd = request.getRequestDispatcher("CompleteLeaveDetail.jsp");
		rd.forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
